<?php
session_start();
if(isset($_SESSION['userword'])){
	echo "<script>alert('在同一台机器上，不允许同时使用用户名和管理员进行登录！');window.location.href='index.php';</script>";
}else{
	include_once("conn/conn.php");
	$usernc=$_POST["usernc"];
	$sql=mysql_query("select usernc from tb_user where usernc='".$usernc."'",$conn);
	$info=mysql_fetch_array($sql);
		if($info){
		echo"<script>alert('对不起，你的昵称已经被占用!');history.back();</script>";
		exit;
	}
$ip=$_SERVER["REMOTE_ADDR"];
if(mysql_query("insert into tb_user(usernc,userpwd,truename,email,qq,tel,ip,address,face,regtime,sex,usertype)values('".$usernc."','".md5(trim($_POST["userpwd"]))."','".$_POST["truename"]."','".$_POST["email"]."','".$_POST["qq"]."','".$_POST["tel"]."','".$ip."','".$_POST["address"]."','".$_POST["face"]."','".date("Y-m-d H:i:s")."','".$_POST["sex"]."','0')",$conn))
{
	$_SESSION["unc"]=$usernc;
	echo"<script>alert('注册成功！');window.location.href='index.php'</script>";
	}else{
		echo"<script>alert('注册失败！');history.back();</script>";
	}
}
?>